home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.4d7 source
/
tn3270 KeyMap
/
keymap.c
next >
Wrap
C/C++ Source or Header
|
1992-04-17
|
39KB
|
1,736 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.4d7 April, 1992
* Copyright (c) 1988, 1989, 1990, 1991, 1992 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistant Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include <QuickDraw.h>
#include <Menus.h>
#include <Dialogs.h>
#include <Memory.h>
#include <SegLoad.h>
#include <Events.h>
#include <TextEdit.h>
#include <ToolUtils.h>
#include <Desk.h>
#include <Windows.h>
#include <Fonts.h>
#include <Files.h>
#include <Devices.h>
#include <Serial.h>
#include <Resources.h>
#include <Packages.h>
#include <Errors.h>
#include <OSEvents.h>
#include <String.h>
#include <Strings.h>
#include <StdIO.h>
#include <CType.h>
#include <StdLib.h>
#define NMENUS 3 /* number of defined menus */
#define appleMenu 256
#define fileMenu 257
#define editMenu 258
#define fileMSize 6 /* size of File menu */
#define DEFAULTNUM 129 /* default resource number */
typedef struct hexinfo {
unsigned char *hexname;
unsigned char hexvalue;
} hexinfo;
typedef struct hexmap {
unsigned short offset;
unsigned char stdchar;
unsigned char aplchar;
} hexmap;
char done; /* true to exit program */
/* screen control rectangles */
/* variables for my window */
MenuHandle myMenus[NMENUS];
struct EventRecord myEvent;
char da_menu;
Rect screenRect; /* rectangle defining screen */
Rect dragRect; /* rectangle defining bounds for dragging */
Rect sizeRect; /* rectangle for resizing windows */
struct Point sfgpoint; /* standard file dialog locations */
struct Point sfppoint;
char defok; /* true if good definition read */
unsigned char mapname[64]; /* name of this mapping */
short mapnum; /* resource number to use */
SFReply defreply; /* info. for definition file */
short myresfile; /* resource file for this program */
short hexcount; /* number of entries used in hexbuff */
unsigned char keybuffn[128]; /* arrays output to resource in this order */
unsigned char keybuffs[128];
unsigned char keybuffc[128];
unsigned char keybuffcs[128];
unsigned char keybuffo[128];
unsigned char ascbuffn[256];
unsigned char ascbuffs[256];
unsigned char ascbuffc[256];
unsigned char ascbuffcs[256];
unsigned char ascbuffo[256];
hexmap hexbuff[256];
void macinit(void);
void macend(void);
void hndmac(void);
void updevent(GrafPtr msgptr);
void menu_upd(void);
void docommand(long mResult);
void appl_menu(void);
void showerr(unsigned char *s);
void showerrln(unsigned char *s, unsigned char *l);
void ctralrt(short a);
OSErr fsrdopen(unsigned char *fname, short vref, short *fref);
void aboutdlg(void);
void ctrwindow(GrafPtr wp);
void framedflt(DialogPtr dlgptr);
OSErr readmap(void);
short newline(unsigned char *text, short lineno);
pascal unsigned short onlydata(FileParam *_pb);
void writetext(void);
OSErr writearray(unsigned char *name, unsigned char *a, short len, short fnum);
OSErr writehex(short fnum);
void writersc(unsigned char new);
OSErr replacedlg(unsigned char *resname);
void showinfo(void);
main()
{
macinit(); /* initialize Mac */
done = 0;
defok = 0;
while (!done) hndmac(); /* handle Mac events and I/O */
macend();
}
void macinit(void)
{
short i, bigscreen;
/* set-up general Macintosh environment */
myresfile = CurResFile();
MaxApplZone(); /* set-up for efficient storage use */
for (i=0; i < 4; i++) MoreMasters();
InitGraf(&qd.thePort);
FlushEvents(everyEvent, 0);
InitWindows();
InitFonts();
InitMenus();
InitDialogs(0L);
InitCursor();
TEInit();
/* set-up menus */
for (i=0; i < NMENUS; i++) {
myMenus[i] = GetMenu(256+i);
InsertMenu(myMenus[i], 0);
}
AddResMenu(myMenus[0], 'DRVR');
da_menu = 0;
appl_menu();
/* center alerts */
ctralrt(256);
ctralrt(260);
screenRect = qd.screenBits.bounds;
bigscreen = (((screenRect.bottom-screenRect.top) >= 480) &&
((screenRect.right-screenRect.left) >= 640));
/* calculate standard file dialog location*/
sfppoint.h = (screenRect.right-screenRect.left-304)/2;
sfgpoint.h = (screenRect.right-screenRect.left-348)/2;
if (bigscreen) {
sfppoint.v = (screenRect.bottom-screenRect.top-184)/3;
sfgpoint.v = (screenRect.bottom-screenRect.top-200)/3;
}
else {
sfppoint.v = (screenRect.bottom-screenRect.top-184)/2;
sfgpoint.v = (screenRect.bottom-screenRect.top-200)/2;
}
SetRect(&dragRect, 0, 24, screenRect.right-4, screenRect.bottom-4);
SetRect(&sizeRect, 50, 25, screenRect.right+1, screenRect.bottom+1);
}
void macend(void)
{
}
void hndmac(void)
{
OSErr rc;
short code;
GrafPtr gp;
unsigned short h, w;
long l;
struct WindowRecord *fw;
WindowPtr whichWindow;
char frontda;
rc = GetNextEvent(everyEvent, &myEvent);
if (rc == 0) /* FALSE from GNE */
switch(myEvent.what) {
case nullEvent:
fw = (WindowRecord *)FrontWindow();
frontda = fw->windowKind < 0;
if (frontda) {
if (!da_menu) {
da_menu = 1;
SetItem(myMenus[1], fileMSize, "\pClose");
appl_menu();
}
}
else {
if (da_menu) {
da_menu = 0;
SetItem(myMenus[1], fileMSize, "\pQuit");
appl_menu();
}
}
SystemTask(); /* run DAs, etc. */
break;
default:
return;
}
else switch(myEvent.what) { /* TRUE from GNE */
case mouseDown:
code = FindWindow(myEvent.where, &whichWindow);
switch (code) {
case inMenuBar:
menu_upd();
docommand(MenuSelect(myEvent.where));
break;
case inSysWindow:
SystemClick(&myEvent, whichWindow);
break;
case inDrag:
if (whichWindow == FrontWindow())
DragWindow(whichWindow, myEvent.where,
&dragRect);
else SelectWindow(whichWindow);
break;
case inGoAway:
break;
case inGrow:
if (whichWindow == FrontWindow()) {
GetPort(&gp);
SetPort(whichWindow);
l = GrowWindow(whichWindow, myEvent.where,
&sizeRect);
h = l >> 16;
w = l & 0x0000ffffL;
SizeWindow(whichWindow, w, h, 0x100);
SetPort(gp);
}
break;
case inContent:
if (whichWindow != FrontWindow()) {
SelectWindow(whichWindow);
break;
}
break;
case inZoomIn:
case inZoomOut:
if (TrackBox(whichWindow, myEvent.where, code)) {
if (((WindowPeek)whichWindow)->dataHandle == 0) break;
GetPort(&gp);
SetPort(whichWindow);
EraseRect(&(((struct WindowRecord *)whichWindow)->port.portRect));
ZoomWindow(whichWindow, code, 0);
SetPort(gp);
}
break;
default:
break;
}
break;
case mouseUp:
break;
case keyDown:
case autoKey:
break;
case activateEvt:
break;
case updateEvt:
updevent((GrafPtr)myEvent.message);
break;
case app4Evt:
break;
default: break;
}
}
void updevent(GrafPtr msgptr)
{
GrafPtr gp;
GetPort(&gp);
SetPort(msgptr);
BeginUpdate(msgptr);
EndUpdate(msgptr);
SetPort(gp);
}
void menu_upd(void)
{
short i;
if (da_menu) {
for (i = 1; i < fileMSize; i++)
DisableItem(myMenus[1], i);
CheckItem(myMenus[1], fileMSize, 0);
}
else {
if (defok) {
for (i = 1; i < fileMSize; i++)
EnableItem(myMenus[1], i);
}
else {
EnableItem(myMenus[1], 1);
for (i = 2; i < fileMSize; i++)
DisableItem(myMenus[1], i);
}
CheckItem(myMenus[1], fileMSize, done << 8);
}
}
void docommand(long mResult)
{
register short theItem, theMenu;
unsigned char name[40];
WindowRecord * fw;
short i;
static char nullstr[1] = {0};
OSErr rc;
theMenu = mResult >> 16;
theItem = mResult & 0xff;
switch(theMenu) {
case appleMenu:
if (theItem == 2) break;
if (theItem == 1) {
aboutdlg();
break;
}
GetItem(myMenus[0], theItem, name);
OpenDeskAcc(name);
break;
case fileMenu:
switch (theItem) {
case 1:
rc = readmap();
defok = (rc == 0);
break;
case 2:
showinfo();
break;
case 3:
writetext();
break;
case 4:
writersc(0);
break;
case 5:
writersc(1);
break;
case 6:
if (!da_menu) {
done ^= 1;
break;
}
else {
fw = (WindowRecord *)FrontWindow();
i = fw->windowKind;
if (i<0) CloseDeskAcc(i);
}
default: break;
}
break;
case editMenu:
SystemEdit(theItem-1);
break;
default:
break;
}
HiliteMenu(0);
appl_menu();
}
void appl_menu(void) /* enable correct application menus */
{
static char last_da = 2; /* init to invalid value */
/* skip drawing menu if no changes from last time */
if (last_da == da_menu) return;
last_da = da_menu; /* save values for next time */
if (da_menu) {
EnableItem(myMenus[2], 0);
}
else {
DisableItem(myMenus[2], 0);
}
DrawMenuBar();
}
void showerr(unsigned char *s)
{
static char nullstr[1] = {0};
c2pstr(s);
ParamText(s, nullstr, nullstr, nullstr);
p2cstr(s);
StopAlert(256, 0L);
ParamText(nullstr, nullstr, nullstr, nullstr);
}
void showerrln(unsigned char *s, unsigned char *l)
{
static char nullstr[1] = {0};
c2pstr(s);
c2pstr(l);
ParamText(s, l, nullstr, nullstr);
p2cstr(s);
p2cstr(l);
StopAlert(260, 0L);
ParamText(nullstr, nullstr, nullstr, nullstr);
}
void ctralrt(short a) /* a = alert number */
{
Handle reshnd;
struct Rect * rptr;
short scrhsize, scrvsize;
short ahsize, avsize;
CouldAlert(a); /* read alert into memory and make unpurgeable */
reshnd = GetResource('ALRT', a);
if (reshnd == 0) return;
rptr = (struct Rect *)*reshnd;
scrhsize = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
scrvsize = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top;
ahsize = rptr->right - rptr->left;
avsize = rptr->bottom - rptr->top;
rptr->top = (scrvsize-avsize)/3;
rptr->left = (scrhsize-ahsize)/2;
rptr->bottom = rptr->top + avsize;
rptr->right = rptr->left + ahsize;
}
OSErr fsrdopen(unsigned char *fname, short vref, short *fref)
{ /* open file read-only */
IOParam pbi;
OSErr rc;
/* initialize parameter block */
memset(&pbi, 0, sizeof(IOParam));
pbi.ioNamePtr = (StringPtr)fname;
pbi.ioVRefNum = vref;
pbi.ioPermssn = fsRdPerm;
rc = PBOpen((ParmBlkPtr)&pbi, 0);
*fref = pbi.ioRefNum;
return(rc);
}
void aboutdlg(void)
{
DialogPtr dlgptr;
short itemHit;
unsigned char **version;
static char nullstr[1] = {0};
dlgptr = GetNewDialog(257, (Ptr)0L, (WindowPtr)-1L);
ctrwindow(dlgptr);
version = GetResource('GFTK', 0);
if (version == 0L) {
DisposDialog(dlgptr);
return;
}
ParamText(*version, nullstr, nullstr, nullstr);
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
ModalDialog(0L, &itemHit);
DisposDialog(dlgptr);
ParamText(nullstr, nullstr, nullstr, nullstr);
}
void ctrwindow(GrafPtr wp)
{
short scrhsize, scrvsize;
short whsize, wvsize;
scrhsize = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
scrvsize = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top;
whsize = wp->portRect.right-wp->portRect.left;
wvsize = wp->portRect.bottom - wp->portRect.top;
MoveWindow(wp, (scrhsize-whsize)/2, (scrvsize-wvsize)/3, 0);
}
void framedflt(DialogPtr dlgptr)
{
short gtype;
Handle gitem;
Rect gbox;
GrafPtr gp;
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
GetPort(&gp);
SetPort(dlgptr);
PenSize(3,3);
InsetRect(&gbox, -4, -4);
FrameRoundRect(&gbox, 16, 16);
SetPort(gp);
}
OSErr readmap(void) /* read definition file to define name and arrays */
{
Point where;
pascal unsigned short (*fileFilter)();
short numTypes;
SFReply reply;
SFTypeList typeList;
DlgHookProcPtr dlgHook;
pascal unsigned short onlydata();
unsigned char errtext[256];
short fref;
OSErr rc;
short linenum, linerc;
unsigned char textchar;
unsigned char textline[256];
short textlen;
unsigned char commentflag;
long fcount;
/* open definition file */
where = sfgpoint;
dlgHook = 0;
fileFilter = onlydata;
numTypes = 2;
typeList[0] = 'TEXT';
typeList[1] = 'ttro';
SFGetFile(where, "\p", (FileFilterProcPtr)fileFilter, numTypes,
&typeList, dlgHook, &reply);
if (reply.good == 0) return(defok == 0); /* user selected "cancel" */
defreply = reply; /* save good data */
rc = fsrdopen(&defreply.fName, defreply.vRefNum, &fref);
if (rc != 0) {
p2cstr(&defreply.fName);
sprintf(errtext, "Error %d opening %s", rc, &defreply.fName);
c2pstr(&defreply.fName);
showerr(errtext);
return(rc);
}
/* read file and process each line */
strcpy(mapname, "unnamed"); /* set default name */
mapnum = DEFAULTNUM; /* set default number */
/* initialize mapping arrays */
memset(keybuffn, 0, 128);
memset(keybuffs, 0, 128);
memset(keybuffc, 0, 128);
memset(keybuffcs, 0, 128);
memset(keybuffo, 0, 128);
memset(ascbuffn, 0, 256);
memset(ascbuffs, 0, 256);
memset(ascbuffc, 0, 256);
memset(ascbuffcs, 0, 256);
memset(ascbuffo, 0, 256);
memset(hexbuff, 0, sizeof(hexmap)*256);
hexcount = 0;
linenum = 0;
textlen = 0;
commentflag = 0;
fcount = 1;
linerc = 0;
rc = FSRead(fref, &fcount, &textchar);
while ((rc == 0) && (linerc == 0)) { /* process new character */
switch (textchar) {
case 0x0d: /* end of line */
linenum++;
textline[textlen] = 0;
linerc = newline(textline, linenum);
textlen = 0;
commentflag = 0;
break;
case '#': /* start of comment */
commentflag = 1;
break;
case 0x00: /* null */
case 0x09: /* tab */
case 0x0a: /* linefeed */
case 0x0b: /* vertical tab */
case 0x0c: /* formfeed */
case 0x20: /* blank */
break;
default:
if (commentflag) break;
if (textlen == 255) {
sprintf(errtext,
"Line %d truncated to first 255 characters:",
linenum+1);
textline[textlen] = 0;
showerrln(errtext, textline);
commentflag = 1;
break;
}
textline[textlen++] = textchar;
break;
}
fcount = 1;
rc = FSRead(fref, &fcount, &textchar);
}
if ((rc != eofErr) && (rc != 0)) {
sprintf(errtext, "Error %d reading definition file.", rc);
showerr(errtext);
FSClose(fref);
return(rc);
}
else if ((textlen > 0) && (linerc == 0)) {
linenum++;
textline[textlen] = 0;
linerc = newline(textline, linenum);
}
FSClose(fref);
return(linerc);
}
short newline(unsigned char *text, short lineno)
{
unsigned char errtext[256];
short textlen, idlen, modlen;
unsigned char textbuff[64];
register int i, j;
unsigned char c, usflag, state;
unsigned char valtype, valnum, idnum, hexnum;
unsigned char id[64];
unsigned char mod[64];
unsigned char * tabptr1, * tabptr2;
unsigned short taboff1, taboff2;
static unsigned char * modnames[] = {
"NORMAL", "SHIFT", "COMMAND", "COMMAND-SHIFT", "OPTION"};
static unsigned char * namelist[] = {
/* 000 */ "SPACE",
/* 001 */ "CENT",
/* 002 */ "PERIOD",
/* 003 */ "LESS",
/* 004 */ "LPAREN",
/* 005 */ "PLUS",
/* 006 */ "OR",
/* 007 */ "AMPERSAND",
/* 008 */ "EXCLAIM",
/* 009 */ "DOLLAR",
/* 010 */ "ASTERISK",
/* 011 */ "RPAREN",
/* 012 */ "SEMI",
/* 013 */ "NOT",
/* 014 */ "MINUS",
/* 015 */ "SLASH",
/* 016 */ "VERTICAL",
/* 017 */ "COMMA",
/* 018 */ "PERCENT",
/* 019 */ "UNDERSCORE",
/* 020 */ "GREATER",
/* 021 */ "QUESTION",
/* 022 */ "ACCENT",
/* 023 */ "COLON",
/* 024 */ "POUND",
/* 025 */ "AT",
/* 026 */ "APOSTROPHE",
/* 027 */ "EQUAL",
/* 028 */ "DBLQUOTE",
/* 029 */ "LCA",
/* 030 */ "LCB",
/* 031 */ "LCC",
/* 032 */ "LCD",
/* 033 */ "LCE",
/* 034 */ "LCF",
/* 035 */ "LCG",
/* 036 */ "LCH",
/* 037 */ "LCI",
/* 038 */ "LCJ",
/* 039 */ "LCK",
/* 040 */ "LCL",
/* 041 */ "LCM",
/* 042 */ "LCN",
/* 043 */ "LCO",
/* 044 */ "LCP",
/* 045 */ "LCQ",
/* 046 */ "LCR",
/* 047 */ "TILDE",
/* 048 */ "LCS",
/* 049 */ "LCT",
/* 050 */ "LCU",
/* 051 */ "LCV",
/* 052 */ "LCW",
/* 053 */ "LCX",
/* 054 */ "LCY",
/* 055 */ "LCZ",
/* 056 */ "LBRACK",
/* 057 */ "RBRACK",
/* 058 */ "LBRACE",
/* 059 */ "A",
/* 060 */ "B",
/* 061 */ "C",
/* 062 */ "D",
/* 063 */ "E",
/* 064 */ "F",
/* 065 */ "G",
/* 066 */ "H",
/* 067 */ "I",
/* 068 */ "RBRACE",
/* 069 */ "J",
/* 070 */ "K",
/* 071 */ "L",
/* 072 */ "M",
/* 073 */ "N",
/* 074 */ "O",
/* 075 */ "P",
/* 076 */ "Q",
/* 077 */ "R",
/* 078 */ "BACKSLASH",
/* 079 */ "S",
/* 080 */ "T",
/* 081 */ "U",
/* 082 */ "V",
/* 083 */ "W",
/* 084 */ "X",
/* 085 */ "Y",
/* 086 */ "Z",
/* 087 */ "0",
/* 088 */ "1",
/* 089 */ "2",
/* 090 */ "3",
/* 091 */ "4",
/* 092 */ "5",
/* 093 */ "6",
/* 094 */ "7",
/* 095 */ "8",
/* 096 */ "9",
/* 097 */ "A_",
/* 098 */ "B_",
/* 099 */ "C_",
/* 100 */ "D_",
/* 101 */ "E_",
/* 102 */ "F_",
/* 103 */ "G_",
/* 104 */ "H_",
/* 105 */ "I_",
/* 106 */ "J_",
/* 107 */ "K_",
/* 108 */ "L_",
/* 109 */ "M_",
/* 110 */ "N_",
/* 111 */ "O_",
/* 112 */ "P_",
/* 113 */ "Q_",
/* 114 */ "R_",
/* 115 */ "S_",
/* 116 */ "T_",
/* 117 */ "U_",
/* 118 */ "V_",
/* 119 */ "W_",
/* 120 */ "X_",
/* 121 */ "Y_",
/* 122 */ "Z_",
/* 123 */ "I-BEAM",
/* 124 */ "DEL-TILDE",
/* 125 */ "GRADE-DOWN",
/* 126 */ "GRADE-UP",
/* 127 */ "VERT-ROTATE",
/* 128 */ "TRANSPOSE",
/* 129 */ "HOR-ROTATE",
/* 130 */ "LOGARITHM",
/* 131 */ "NOR",
/* 132 */ "NAND",
/* 133 */ "APL-EXCLAIM",
/* 134 */ "DOMINO",
/* 135 */ "QUOTE-QUAD",
/* 136 */ "DELTA_",
/* 137 */ "FORMAT",
/* 138 */ "EXECUTE",
/* 139 */ "LAMP",
/* 140 */ "EXPAND",
/* 141 */ "COMPRESS",
/* 142 */ "ENTER",
/* 143 */ "PF1",
/* 144 */ "PF2",
/* 145 */ "PF3",
/* 146 */ "PF4",
/* 147 */ "PF5",
/* 148 */ "PF6",
/* 149 */ "PF7",
/* 150 */ "PF8",
/* 151 */ "PF9",
/* 152 */ "PF10",
/* 153 */ "PF11",
/* 154 */ "PF12",
/* 155 */ "PF13",
/* 156 */ "PF14",
/* 157 */ "PF15",
/* 158 */ "PF16",
/* 159 */ "PF17",
/* 160 */ "PF18",
/* 161 */ "PF19",
/* 162 */ "PF20",
/* 163 */ "PF21",
/* 164 */ "PF22",
/* 165 */ "PF23",
/* 166 */ "PF24",
/* 167 */ "PA1",
/* 168 */ "PA2",
/* 169 */ "PA3",
/* 170 */ "CLEAR",
/* 171 */ "TREQ",
/* 172 */ "CURSEL",
/* 173 */ "UP",
/* 174 */ "DOWN",
/* 175 */ "LEFT",
/* 176 */ "RIGHT",
/* 177 */ "TAB",
/* 178 */ "BACKTAB",
/* 179 */ "NEWLINE",
/* 180 */ "HOME",
/* 181 */ "ERASE-EOF",
/* 182 */ "ERASE-INPUT",
/* 183 */ "INSERT-MODE",
/* 184 */ "DELETE-CHAR",
/* 185 */ "RESET",
/* 186 */ "DUP",
/* 187 */ "FIELD-MARK",
/* 188 */ "APL-MODE",
/* 189 */ "INSERT-CHAR",
/* 190 */ "RUB-OUT",
/* 191 */ "UP*2",
/* 192 */ "DOWN*2",
/* 193 */ "LEFT*2",
/* 194 */ "RIGHT*2",
/* 195 */ "CURSOR-POS",
/* 196 */ "PROG-RESET",
/* 197 */ "PRINT-SCREEN",
};
static hexinfo hexlist[] = {
{"SUBFIELD_DELIMITER", 0x1F},
{"END_OF_LINE", 0x2A},
{"START_OF_MESSAGE", 0x38},
{"PARAGRAPH", 0x39},
{"DAGGER", 0x3A},
{"DOUBLE_DAGGER", 0x3B},
{"POLISH_L_UPPER", 0x41},
{"SCANDINAVIAN_O_UPPER", 0x42},
{"D_WITH_CROSSBAR_UPPER", 0x43},
{"ICELANDIC_THORN_UPPER", 0x44},
{"DIGRAPH_AE_UPPER", 0x45},
{"DIGRAPH_OE_UPPER", 0x46},
{"O-HOOK_UPPER", 0x47},
{"U-HOOK_UPPER", 0x48},
{"SOFT_SIGN", 0x49},
{"POLISH_L_LOWER", 0x51},
{"SCANDINAVIAN_O_LOWER", 0x52},
{"D_WITH_CROSSBAR_LOWER", 0x53},
{"ICELANDIC_THORN_LOWER", 0x54},
{"DIGRAPH_AE_LOWER", 0x55},
{"DIGRAPH_OE_LOWER", 0x56},
{"O-HOOK_LOWER", 0x57},
{"U-HOOK_LOWER", 0x58},
{"HARD_SIGN", 0x59},
{"AYN", 0x62},
{"ALIF", 0x63},
{"DOT_IN_MIDDLE_OF_LINE", 0x64},
{"TURKISH_I_LOWER", 0x65},
{"MUSICAL_FLAT", 0x66},
{"SUBSCRIPT_PATENT_MARK", 0x67},
{"ETH", 0x68},
{"PLUS_OR_MINUS", 0x69},
{"SUB0", 0x70},
{"SUB1", 0x71},
{"SUB2", 0x72},
{"SUB3", 0x73},
{"SUB4", 0x74},
{"SUB5", 0x75},
{"SUB6", 0x76},
{"SUB7", 0x77},
{"SUB8", 0x78},
{"SCRIPT_L", 0x80},
{"CIRCLE_ABOVE", 0x8A},
{"SUPERIOR_DOT", 0x8B},
{"UMLAUT", 0x8C},
{"CANDRABINDU", 0x8D},
{"LIGATURE_FIRST_HALF", 0x8E},
{"DOUBLE_TILDE_FIRST_HALF", 0x8F},
{"SUB9", 0x90},
{"GRAVE", 0x9A},
{"ACUTE", 0x9B},
{"ALA_CIRCUMFLEX", 0x9C},
{"HACEK", 0x9D},
{"LIGATURE_SECOND_HALF", 0x9E},
{"DOUBLE_TILDE_SECOND_HALF", 0x9F},
{"ALA_DAGGER", 0xA0},
{"SUB_PLUS", 0xAA},
{"SUB_LPAREN", 0xAB},
{"PINCUSHION", 0xAC},
{"SUB_MINUS", 0xAE},
{"SUB_RPAREN", 0xAF},
{"SUP0", 0xB0},
{"SUP1", 0xB1},
{"SUP2", 0xB2},
{"SUP3", 0xB3},
{"SUP4", 0xB4},
{"SUP5", 0xB5},
{"SUP6", 0xB6},
{"SUP7", 0xB7},
{"SUP8", 0xB8},
{"SUP9", 0xB9},
{"SUP_PLUS", 0xBA},
{"SUP_LPAREN", 0xBB},
{"ASPER", 0xBC},
{"SUP_MINUS", 0xBE},
{"SUP_RPAREN", 0xBF},
{"CIRCLE_BELOW", 0xCA},
{"DOT_BELOW", 0xCB},
{"DOUBLE_DOT_BELOW", 0xCC},
{"BREVE", 0xCD},
{"ALA_TILDE", 0xCE},
{"PSEUDO_QUESTION", 0xCF},
{"CEDILLA", 0xDA},
{"HIGH_COMMA_CENTERED", 0xDB},
{"RIGHT_HOOK", 0xDC},
{"UPADHMANIYA", 0xDD},
{"MACRON", 0xDE},
{"DOUBLE_ACUTE", 0xDF},
{"BRITISH_POUND", 0xE1},
{"RIGHT_CEDILLA", 0xEA},
{"HIGH_COMMA_OFF_CENTER", 0xEB},
{"LEFT_HOOK/TAIL", 0xEC},
{"ALA_UNDERSCORE", 0xED},
{"DOUBLE_UNDERSCORE", 0xEE},
{"ALA_ALPHA", 0xFA},
{"ALA_BETA", 0xFB},
{"ALA_GAMMA", 0xFC},
{"YEN", 0xFD},
{"PESO", 0xFE}};
textlen = strlen(text);
/* skip null lines */
if (textlen == 0) return (0);
/* check for name definition line */
if (textlen > 5) {
for (i=0; i < 5; i++)
textbuff[i] = toupper(text[i]);
if (strncmp(textbuff, "NAME:", 5) == 0) {
i = 0;
j = i + 5;
usflag = 0;
while (i < 63) {
c = text[j++];
if (usflag) {
if (c == '_') {
mapname[i++] = '_';
}
else {
mapname[i++] = ' ';
if (i < 63) {
mapname[i++] = c;
if (c == 0) break;
}
}
usflag = 0;
}
else if (c == '_') {
usflag = 1;
}
else {
mapname[i++] = c;
if (c == 0) break;
}
}
mapname[63] = 0;
return(0);
}
}
/* check for number definition line */
if (textlen > 7) {
for (i=0; i < 7; i++)
textbuff[i] = toupper(text[i]);
if (strncmp(textbuff, "NUMBER:", 7) == 0) {
c = 0;
for (i=7; i < textlen; i++) {
c = text[i];
if ((c < '0') || (c > '9')) break;
}
if ((c >= '0') && (c <= '9')) {
mapnum = atoi(text+7);
return(0);
}
}
}
/* process mapping definition line */
state = 0;
idlen = modlen = 0;
for (i=0; i < textlen; i++) {
c = text[i];
switch(state) {
case 0: /* first character */
if (c == '=') {
state = 99;
}
else {
id[idlen++] = toupper(c);
state = 1;
}
break;
case 1: /* characters of id */
if (c == '=') {
id[idlen] = 0;
state = 2;
}
else {
if (idlen < 63) id[idlen++] = toupper(c);
else state = 99;
}
break;
case 2: /* characters in modifier */
if (c == '\'') {
mod[modlen] = 0;
state = 3;
}
else if (c == '"') {
mod[modlen] = 0;
state = 5;
}
else {
if (modlen < 63) mod[modlen++] = toupper(c);
else state = 99;
}
break;
case 3: /* literal character value */
valtype = 0;
valnum = c;
state = 4;
break;
case 4: /* end of character literal */
if (c == '\'') state = 9;
else state = 99;
break;
case 5: /* start of hex string */
c = toupper(c);
if ((c >= 'A') && (c <= 'F')) {
valtype = 0;
valnum = (c - 'A' + 10) << 4;
state = 7;
}
else if ((c >= '0') && (c <= '9')) {
valtype = 0;
valnum = (c - '0') << 4;
state = 7;
}
else if (c == 'K') {
valtype = 6;
state = 6;
}
else state = 99;
break;
case 6: /* after "K" in string */
c = toupper(c);
if ((c >= 'A') && (c <= 'F')) {
valnum = (c - 'A' + 10) << 4;
state = 7;
}
else if ((c >= '0') && (c <= '9')) {
valnum = (c - '0') << 4;
state = 7;
}
else state = 99;
break;
case 7: /* after first hex digit */
c = toupper(c);
if ((c >= 'A') && (c <= 'F')) {
valnum += c - 'A' + 10;
state = 8;
}
else if ((c >= '0') && (c <= '9')) {
valnum += c - '0';
state = 8;
}
else state = 99;
break;
case 8: /* end of hex string */
if (c == '"') state = 9;
else state = 99;
break;
case 9: /* after complete definition */
default:
state = 99;
break;
}
if (state == 99) break; /* syntax error */
}
if (state != 9) { /* error if not in finishing state */
sprintf(errtext, "Syntax error in definition file at line %d:",
lineno);
showerrln(errtext, text);
return(4);
}
/* apply modifier, if any to valtype */
if (modlen > 0) {
j = -1;
for (i=0; i < sizeof(modnames) >> 2; i++) {
if (strcmp(mod, modnames[i]) == 0) {
j = i;
break;
}
}
if (j < 0) {
sprintf(errtext, "Invalid modifier value '%s' at line %d:",
mod, lineno);
showerrln(errtext, text);
return(8);
}
else valtype += j+1;
}
/* check that keycode value is legal */
if ((valtype >= 6) && (valnum > 127)) {
sprintf(errtext, "Key code '%x' exceeds 7f at line %d:",
valnum, lineno);
showerrln(errtext, text);
return(12);
}
/* convert function id table index */
j = -1;
for (i=0; i < sizeof(namelist) >> 2; i++) {
if (strcmp(id, namelist[i]) == 0) {
j = i;
break;
}
}
if (j >= 0) {
idnum = j;
hexnum = 0;
}
else { /* search hex name table */
for (i=0; i < sizeof(hexlist)/sizeof(hexinfo); i++) {
if (strcmp(id, (hexlist[i]).hexname) == 0) {
idnum = j = 254;
hexnum = (hexlist[i]).hexvalue;
break;
}
}
}
if (j < 0) {
sprintf(errtext, "Invalid key or function name '%s' at line %d:",
id, lineno);
showerrln(errtext, text);
return(16);
}
tabptr2 = 0;
switch(valtype) {
case 0: tabptr1 = ascbuffn;
taboff1 = 5*128;
tabptr2 = ascbuffs;
taboff2 = 7*128;
break;
case 1: tabptr1 = ascbuffn;
taboff1 = 5*128;
break;
case 2: tabptr1 = ascbuffs;
taboff1 = 7*128;
break;
case 3: tabptr1 = ascbuffc;
taboff1 = 9*128;
break;
case 4: tabptr1 = ascbuffcs;
taboff1 = 11*128;
break;
case 5: tabptr1 = ascbuffo;
taboff1 = 13*128;
break;
case 6: tabptr1 = keybuffn;
taboff1 = 0;
break;
case 7: tabptr1 = keybuffn;
taboff1 = 0;
break;
case 8: tabptr1 = keybuffs;
taboff1 = 128;
break;
case 9: tabptr1 = keybuffc;
taboff1 = 2*128;
break;
case 10: tabptr1 = keybuffcs;
taboff1 = 3*128;
break;
case 11: tabptr1 = keybuffo;
taboff1 = 4*128;
break;
default:
return(20); /* can't happen */
break;
}
tabptr1 += valnum;
if ((*tabptr1) == 0) {
(*tabptr1) = idnum + 1;
if (hexnum > 0) {
if (hexcount == 256) {
sprintf(errtext, "Number of hex mappings exceeds 256 at line %d:",
lineno);
showerrln(errtext, text);
return(16);
}
(hexbuff[hexcount]).offset = taboff1 + valnum;
(hexbuff[hexcount]).stdchar = hexnum;
(hexbuff[hexcount++]).aplchar = 0;
}
}
else {
sprintf(errtext, "Duplicate key definition at line %d:",
lineno);
showerrln(errtext, text);
return(24);
}
if (tabptr2 != 0) {
tabptr2 += valnum;
if ((*tabptr2) == 0) {
(*tabptr2) = idnum + 1;
if (hexnum > 0) {
if (hexcount == 256) {
sprintf(errtext, "Number of hex mappings exceeds 256 at line %d:",
lineno);
showerrln(errtext, text);
return(16);
}
(hexbuff[hexcount]).offset = taboff2 + valnum;
(hexbuff[hexcount]).stdchar = hexnum;
(hexbuff[hexcount++]).aplchar = 0;
}
}
else {
sprintf(errtext, "Duplicate key definition at line %d:",
lineno);
showerrln(errtext, text);
return(24);
}
}
return (0);
}
pascal unsigned short onlydata(FileParam *_pb)
{
if (_pb->ioFlLgLen == 0L) return(0x100);
else return(0);
}
void writetext(void) /* write resource to Rez format file */
{
Point where;
DlgHookProcPtr dlgHook;
SFReply reply;
OSErr rc;
short fnum;
unsigned char outtext[256];
long outcount;
where = sfppoint;
dlgHook = 0;
strcpy(outtext, mapname);
strcat(outtext, ".r");
c2pstr(outtext);
SFPutFile(where, "\pSave in Rez format as:",
outtext, dlgHook, &reply);
p2cstr(outtext);
if (reply.good == 0) return;
rc = FSDelete(&reply.fName, reply.vRefNum); /* delete existing file */
rc = Create(&reply.fName, reply.vRefNum, 'MPS ', 'TEXT');
if (rc != 0) {
sprintf(outtext, "Error %d creating output file.", rc);
showerr(outtext);
return;
}
rc = FSOpen(&reply.fName, reply.vRefNum, &fnum);
if (rc != 0) {
sprintf(outtext, "Error %d opening output file.", rc);
showerr(outtext);
return;
}
sprintf(outtext, "data \'GFKB\' (%d, \"%s\", preload) {\n",
mapnum, mapname);
outcount = strlen(outtext);
rc = FSWrite(fnum, &outcount, outtext);
if (rc == 0)
rc = writearray("keybuffn", keybuffn, 128, fnum);
if (rc == 0)
rc = writearray("keybuffs", keybuffs, 128, fnum);
if (rc == 0)
rc = writearray("keybuffc", keybuffc, 128, fnum);
if (rc == 0)
rc = writearray("keybuffcs", keybuffcs, 128, fnum);
if (rc == 0)
rc = writearray("keybuffo", keybuffo, 128, fnum);
if (rc == 0)
rc = writearray("ascbuffn", ascbuffn, 256, fnum);
if (rc == 0)
rc = writearray("ascbuffs", ascbuffs, 256, fnum);
if (rc == 0)
rc = writearray("ascbuffc", ascbuffc, 256, fnum);
if (rc == 0)
rc = writearray("ascbuffcs", ascbuffcs, 256, fnum);
if (rc == 0)
rc = writearray("ascbuffo", ascbuffo, 256, fnum);
if ((hexcount > 0) && (rc == 0))
rc = writehex(fnum);
if (rc == 0) {
sprintf(outtext, "};\n");
outcount = strlen(outtext);
rc = FSWrite(fnum, &outcount, outtext);
}
if (rc != 0) {
sprintf(outtext, "Error %d writing output file.", rc);
showerr(outtext);
}
FSClose(fnum);
}
OSErr writearray(unsigned char *name, unsigned char *a, short len, short fnum)
{
OSErr rc;
long outcount;
register int i, j;
unsigned char outtext[256];
sprintf(outtext, "\t\t\t\t\t\t\t\t\t\t\t/* %s */\n", name);
outcount = strlen(outtext);
rc = FSWrite(fnum, &outcount, outtext);
if (rc != 0) return(rc);
for (i = 0; i < len; i +=16) {
sprintf(outtext,
"$\"%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x\"\n",
a[i], a[i+1], a[i+2], a[i+3], a[i+4], a[i+5], a[i+6], a[i+7],
a[i+8], a[i+9], a[i+10], a[i+11], a[i+12], a[i+13], a[i+14], a[i+15]);
for (j=0; j < strlen(outtext); j++)
outtext[j] = toupper(outtext[j]);
outcount = strlen(outtext);
rc = FSWrite(fnum, &outcount, outtext);
if (rc != 0) return(rc);
}
return(0);
}
OSErr writehex(short fnum)
{
OSErr rc;
long outcount;
register int i, j;
unsigned char outtext[256];
unsigned char *a;
int wholelines, extrawords;
unsigned char wordbuff[12];
sprintf(outtext, "\t\t\t\t\t\t\t\t\t\t\t/* %s */\n", "hexbuff");
outcount = strlen(outtext);
rc = FSWrite(fnum, &outcount, outtext);
if (rc != 0) return(rc);
wholelines = hexcount / 4;
extrawords = hexcount % 4;
a = (unsigned char *)hexbuff;
i = 0;
if (wholelines > 0) {
for (i = 0; i < wholelines*16; i +=16) {
sprintf(outtext,
"$\"%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x\"\n",
a[i], a[i+1], a[i+2], a[i+3], a[i+4], a[i+5], a[i+6], a[i+7],
a[i+8], a[i+9], a[i+10], a[i+11], a[i+12], a[i+13], a[i+14], a[i+15]);
for (j=0; j < strlen(outtext); j++)
outtext[j] = toupper(outtext[j]);
outcount = strlen(outtext);
rc = FSWrite(fnum, &outcount, outtext);
if (rc != 0) return(rc);
}
}
if (extrawords > 0) {
strcpy(outtext, "$\"");
for (j = 0; j < extrawords; j++) {
if (j > 0) strcat(outtext, " ");
sprintf(wordbuff, "%02x%02x %02x%02x", a[i], a[i+1], a[i+2], a[i+3]);
strcat(outtext, wordbuff);
i += 4;
}
strcat(outtext, "\"\n");
for (j=0; j < strlen(outtext); j++)
outtext[j] = toupper(outtext[j]);
outcount = strlen(outtext);
rc = FSWrite(fnum, &outcount, outtext);
if (rc != 0) return(rc);
}
return(0);
}
void writersc(unsigned char new)
{
Point where;
DlgHookProcPtr dlgHook;
FileFilterProcPtr fileFilter;
SFReply reply;
short numTypes;
SFTypeList typeList;
OSErr rc;
unsigned char errtext[256];
short currvol, rfile;
Handle temph;
short i, newnum, resid, rescount;
ResType restype;
unsigned char resname[256];
char resexists;
Size mapsize;
unsigned char * sourceptr, *destptr;
unsigned short resattr;
if (new) { /* create new file */
where = sfppoint;
dlgHook = 0;
c2pstr(mapname);
SFPutFile(where, "\pNew resource file:",
mapname, dlgHook, &reply);
p2cstr(mapname);
if (reply.good == 0) return;
rc = FSDelete(&reply.fName, reply.vRefNum); /* delete existing file */
rc = Create(&reply.fName, reply.vRefNum, 'GFKM', 'GFKB');
if (rc != 0) {
sprintf(errtext, "Error %d creating output file.", rc);
showerr(errtext);
return;
}
}
else { /* get existing resource file */
where = sfgpoint;
dlgHook = 0;
fileFilter = 0;
numTypes = 2;
typeList[0] = 'APPL';
typeList[1] = 'GFKB';
SFGetFile(where, "\p", fileFilter, numTypes,
&typeList, dlgHook, &reply);
if (reply.good == 0) return; /* user selected "cancel" */
}
/* the file we want to open is defined by reply.fName and reply.vRefNum */
GetVol(errtext, &currvol);
SetVol(0L, reply.vRefNum);
rfile = OpenResFile(&reply.fName);
newnum = 0;
resexists = 0;
if (rfile != -1) {
rescount = CountResources('GFKB');
if (rescount > 0) {
for (i=1; i <= rescount; i++) {
SetResLoad(0); /* don't load resources */
temph = GetIndResource('GFKB', i);
SetResLoad(0x101); /* restore loading */
if (HomeResFile(temph) != rfile) break;
GetResInfo(temph, &resid, &restype, resname);
c2pstr(mapname);
if (EqualString(resname, mapname, 0, 0x101) != 0) {
p2cstr(mapname);
resexists = 1;
break;
}
else {
p2cstr(mapname);
if (resid > newnum) newnum = resid;
}
}
}
}
if (resexists) newnum = resid;
else {
if (newnum < 128) newnum = 128;
else newnum++;
}
if (resexists) {
UseResFile(myresfile);
rc = replacedlg(resname);
UseResFile(rfile);
if (rc) {
RmveResource(temph);
if (rc = ResError()) {
CloseResFile(rfile);
SetVol(0L, currvol);
sprintf(errtext, "Error %d deleting resource from file", rc);
showerr(errtext);
return;
}
}
else {
CloseResFile(rfile);
SetVol(0L, currvol);
return;
}
}
if (rfile != -1) CloseResFile(rfile);
CreateResFile(&reply.fName);
rfile = OpenResFile(&reply.fName);
if (rfile == -1) {
SetVol(0L, currvol);
sprintf(errtext, "Error %d opening resource file", ResError());
showerr(errtext);
return;
}
/* get handle to data to write out */
mapsize = sizeof(keybuffn);
mapsize += sizeof(keybuffs);
mapsize += sizeof(keybuffc);
mapsize += sizeof(keybuffcs);
mapsize += sizeof(keybuffo);
mapsize += sizeof(ascbuffn);
mapsize += sizeof(ascbuffs);
mapsize += sizeof(ascbuffc);
mapsize += sizeof(ascbuffcs);
mapsize += sizeof(ascbuffo);
mapsize += sizeof(hexmap) * hexcount;
temph = NewHandle(mapsize);
if (temph == 0) {
CloseResFile(rfile);
SetVol(0L, currvol);
sprintf(errtext, "Out of memory allocating resource");
showerr(errtext);
return;
}
destptr = *temph;
sourceptr = keybuffn;
memcpy(destptr, sourceptr, sizeof(keybuffn));
destptr += sizeof(keybuffn);
sourceptr = keybuffs;
memcpy(destptr, sourceptr, sizeof(keybuffs));
destptr += sizeof(keybuffs);
sourceptr = keybuffc;
memcpy(destptr, sourceptr, sizeof(keybuffc));
destptr += sizeof(keybuffc);
sourceptr = keybuffcs;
memcpy(destptr, sourceptr, sizeof(keybuffcs));
destptr += sizeof(keybuffcs);
sourceptr = keybuffo;
memcpy(destptr, sourceptr, sizeof(keybuffo));
destptr += sizeof(keybuffo);
sourceptr = ascbuffn;
memcpy(destptr, sourceptr, sizeof(ascbuffn));
destptr += sizeof(ascbuffn);
sourceptr = ascbuffs;
memcpy(destptr, sourceptr, sizeof(ascbuffs));
destptr += sizeof(ascbuffs);
sourceptr = ascbuffc;
memcpy(destptr, sourceptr, sizeof(ascbuffc));
destptr += sizeof(ascbuffc);
sourceptr = ascbuffcs;
memcpy(destptr, sourceptr, sizeof(ascbuffcs));
destptr += sizeof(ascbuffcs);
sourceptr = ascbuffo;
memcpy(destptr, sourceptr, sizeof(ascbuffo));
destptr += sizeof(ascbuffo);
sourceptr = (unsigned char *)hexbuff;
memcpy(destptr, sourceptr, sizeof(hexmap) * hexcount);
/* Add the new resource (finally!) */
c2pstr(mapname);
AddResource(temph, 'GFKB', newnum, mapname);
p2cstr(mapname);
if (rc = ResError()) {
CloseResFile(rfile);
SetVol(0L, currvol);
sprintf(errtext, "Error %d adding resource to file", rc);
showerr(errtext);
return;
}
resattr = GetResAttrs(temph);
if (rc = ResError()) {
CloseResFile(rfile);
SetVol(0L, currvol);
sprintf(errtext, "Error %d getting resource attributes", rc);
showerr(errtext);
return;
}
resattr |= resPreload;
SetResAttrs(temph, resattr);
if (rc = ResError()) {
CloseResFile(rfile);
SetVol(0L, currvol);
sprintf(errtext, "Error %d setting resource attributes", rc);
showerr(errtext);
return;
}
CloseResFile(rfile);
if (rc = ResError()) {
sprintf(errtext, "Error %d closing resource to file", rc);
showerr(errtext);
}
SetVol(0L, currvol);
return;
}
OSErr replacedlg(unsigned char *resname)
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short itemHit;
static char nullstr[1] = {0};
dStorage = 0;
behind = (WindowPtr)-1;
ParamText(resname, nullstr, nullstr, nullstr);
dlgptr = GetNewDialog(258, dStorage, behind);
ctrwindow(dlgptr);
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
filterProc = 0;
ModalDialog((ModalFilterProcPtr)filterProc, &itemHit);
DisposDialog(dlgptr);
ParamText(nullstr, nullstr, nullstr, nullstr);
if (itemHit == 2) return(1);
else return(0);
}
void showinfo(void)
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short itemHit;
static char nullstr[1] = {0};
unsigned char numtext[32];
unsigned char datestr[516];
short datelen;
FileParam fp;
fp.ioNamePtr = &defreply.fName;
fp.ioVRefNum = defreply.vRefNum;
fp.ioFVersNum = 0;
fp.ioFDirIndex = 0;
PBGetFInfo((ParmBlkPtr)&fp, 0);
IUDateString(fp.ioFlMdDat, 2, datestr);
p2cstr(datestr);
strcat(datestr, " ");
datelen = strlen(datestr);
IUTimeString(fp.ioFlMdDat, 1, datestr+datelen);
p2cstr(datestr+datelen);
sprintf(numtext, "%d", mapnum);
c2pstr(datestr);
c2pstr(mapname);
c2pstr(numtext);
ParamText(&defreply.fName, datestr, mapname, numtext);
p2cstr(datestr);
p2cstr(mapname);
p2cstr(numtext);
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(259, dStorage, behind);
ctrwindow(dlgptr);
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
filterProc = 0;
ModalDialog((ModalFilterProcPtr)filterProc, &itemHit);
DisposDialog(dlgptr);
ParamText(nullstr, nullstr, nullstr, nullstr);
}